<script src="./fuentes/view/bleu/js/script_ajax_bleu_ranking_visitas.js" type="text/javascript"></script>
<div class="clearfix"></div>
<div class="content">    
    <!-- Modal -->
    <div class="modal fade" id="filtroRankingBleu" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><br>
                    <i class="icon-credit-card icon-7x"></i>
                    <h4 id="myModalLabel" class="semi-bold">Filtros</h4>
                    <p class="no-margin"> </p>
                    <br>
                </div>
                <form  action="./fuentes/controller/BleuRankingVisitas.php" id="formFiltroRankingBleu" name="formFiltroRankingBleu" autocomplete="off" > 
                    <div class="modal-body">
                        <div class="row form-row">
                            <div class="col-md-6">
                                <label class="form-label">Fecha Desde</label>
                                <input class="form-control" type="date" id="fechaDesde" name="fechaDesde"  placeholder="FECHA INICIAL"
                                       value="<?php
                                       if ($filtro['fechaDesde']) {
                                           $date = new DateTime($filtro['fechaDesde']);
                                           echo $date->format('Y-m-d');
                                       } else
                                           echo "";
                                       ?>" >
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Fecha Hasta</label>
                                <input class="form-control" type="date" id="fechaHasta" name="fechaHasta"  placeholder="FECHA FINAL"
                                       value="<?php
                                       if ($filtro['fechaHasta']) {
                                           $date = new DateTime($filtro['fechaHasta']);
                                           echo $date->format('Y-m-d');
                                       } else
                                           echo "";
                                       ?>" >
                            </div>
                        </div>
                        <div class="row form-row">
                            <div class="col-md-6">
                                <label class="form-label">Roles</label>
                                <br/>
                                <div class="radio radio-success">
                                    <input id="miembros" type="radio" name="rol" value="miembros" <?php if ($filtro["rol"] === 'miembros') echo "checked='checked'"; ?> >
                                    <label for="miembros">MIEMBROS</label>

                                    <input id="invitados" type="radio" name="rol" value="invitados" <?php if ($filtro["rol"] === 'invitados') echo "checked='checked'"; ?> >
                                    <label for="invitados">INVITADOS</label>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Cantidad de Registros</label>
                                <select class="form-control" id="limite" name="limite">
                                    <option value="10"  <?php if ($filtro["limite"] == '10') echo "selected"; ?> >10</option>
                                    <option value="20"  <?php if ($filtro["limite"] == '20') echo "selected"; ?> >20</option>
                                    <option value="30"  <?php if ($filtro["limite"] == '30') echo "selected"; ?> >30</option>
                                    <option value="40"  <?php if ($filtro["limite"] == '40') echo "selected"; ?> >40</option>
                                    <option value="50"  <?php if ($filtro["limite"] == '50') echo "selected"; ?> >50</option>
                                    <option value="100"  <?php if ($filtro["limite"] == '100') echo "selected"; ?> >100</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" onclick="clearForm();" data-dismiss="modal">Cancelar</button>
                        <button type="submit" id="aplicar_filtros" class="btn btn-success btn-cons">Listar</button>
                        <img id="loading" src="web/assets/img/ajax_load.gif" alt="loading" style="visibility: hidden; "/>
                    </div>
                </form>    
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->

    <div class="row" id="rankingBleuView">
        <div class="col-md-12">
            <div class="grid simple ">
                <div class="grid-title no-border">
                    <h4><span class="semi-bold">Ranking de Visitas Bleu Bar Club</span></h4>
                    <button style="float: right;" class="btn btn-success btn-xs " id="filtros" data-toggle="modal"  data-target="#filtroRankingBleu"> Filtros</button>
                    <div class="labelRight" id="error"></div>
                </div>
                <div class="grid-body no-border">
                    <table class="table table-hover no-more-tables table-condensed" id="rankingBleuTABLE">
                        <thead>
                            <tr>
                                <th class='text-center' style="width:5%" >N&deg;</th>
                                <th style="width:25%">NOMBRE Y APELLIDO</th>
                                <th style="width:6%">VISITAS</th>
                                <th class='text-left' style="width:25%">PRIMER EVENTO</th>
                                <th  class='text-left' style="width:25%">ÚLTIMO EVENTO</th>
                            </tr>
                        </thead>
                        <tbody id="rankingList">
                            <?php
                            if ($listado) {
                                $a = 1;
                                foreach ($listado as $dato) {
                                    echo "<tr >"
                                    . "<td class='text-center'>" . $a++ . "</td>"
                                    . "<td class='text-left'>" . $dato["nombre"] . "</td>"
                                    . "<td class='text-center'>" . $dato["visitas"] . "</td>"
                                    . "<td class='text-left'>" . $dato["primer_evento"] . "</td>"
                                    . "<td class='text-left'>" . $dato["ultimo_evento"] . "</td>"
                                    . "</tr>";
                                }
                            } else {
                                echo "<tr><td colspan='5' class='text-center'><h4> No existen Registros </h4></td></tr>";
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>